#include <cstdio>
#include <cstring>
#include <cmath>

#define INC(x, y) (x=(x+(y))%mods)

using namespace std;

typedef long long ll;
const int maxn=15000, maxs=10, sqrtm=10000, mods=998244353;

ll qpow(ll a, int n) {
    ll s=1;
    for (; n; n/=2) {
        if (n&1) s=s*a%mods;
        a=a*a%mods;
    }
    return s;
}

ll fact[maxn+1], invf[maxn+1];

void initFact(int n) {
    fact[0] = 1;
    for (int i=1; i<=n; i++) fact[i] = fact[i-1]*i%mods;
    invf[n] = qpow(fact[n], mods-2);
    for (int i=n; i; i--) invf[i-1] = invf[i]*i%mods;
}

int n;

ll solve(int m) {
    static int p[sqrtm+1], q[sqrtm+1];
    p[0] = q[0] = 0;
    for (int i=1, t=sqrt(m); i<=t && i<=n; i++) {
        if (m%i==0) {
            p[++p[0]] = i;
            if (m/i!=i && m/i<=n) q[++q[0]] = m/i;
        }
    }
    for (; q[0]; ) p[++p[0]] = q[q[0]--];

    static ll f[maxn+1];
    f[0] = 1;
    for (int i=1; i<=n; i++) {
        f[i] = 0;
        for (int j=1; j<=p[0] && p[j]<=i; j++) {
            INC(f[i], f[i-p[j]]*fact[n-i+p[j]-1]);
        }
        f[i] = f[i]*invf[n-i]%mods;
    }
    return f[n];
}

int main() {
    freopen("elegance.in", "r", stdin);
    freopen("elegance.out", "w", stdout);

    int m;
    scanf("%d %d", &n, &m);
    initFact(n);

    static int p[maxs+1];
    int t=m;
    for (int i=2; i<=sqrt(t); i++) {
        if (t%i==0) p[++p[0]] = i;
        for (; t%i==0; t/=i);
    }
    if (t>1) p[++p[0]] = t;

    ll ans=0;
    for (int i=0; i<(1<<p[0]); i++) {
        t = m;
        int cnt=0;
        for (int j=1; j<=p[0]; j++) {
            if ((i>>(j-1))&1) {
                cnt++;
                t/=p[j];
            }
        }
        INC(ans, cnt%2 ? mods-solve(t) : solve(t));
    }
    printf("%lld\n", ans);

    fclose(stdin);
    fclose(stdout);
    return 0;
}
